package com.jic.market.controller.manage;

import com.alibaba.fastjson.JSON;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.entity.base.BaseActivity;
import com.jic.market.request.manager.overlay.QueryPagePromotionRequest;
import com.jic.market.response.PageResponse;
import com.jic.market.response.manager.base.BaseActivityResponse;
import com.jic.market.response.manager.overlay.QueryPagePromotionResponse;
import com.jic.market.service.base.BaseActivityService;
import com.jic.market.service.overlay.OverlayBaseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/baseActivity")
@Api(tags = {"后端调用-秒杀"})
@Slf4j
public class BaseActivityController {

    @Autowired
    private OverlayBaseInfoService overlayBaseInfoService;
    @Autowired
    private BaseActivityService baseActivityService;
    /**
     * 分页查询
     * @param servletRequest
     * @param request
     * @return
     */
    @PostMapping("/listByPage")
    @ResponseBody
    @ApiOperation(value = "分页查询")
    public RestResult<PageResult<BaseActivity>> list(HttpServletRequest servletRequest, @RequestBody BaseActivity request){
        log.info("分页查询通用活动，入参{}", JSON.toJSONString(request));
        Page page = new Page();
        page.setLimit(request.getLimit());
        page.setStart(request.getStart());
        PageResult<BaseActivity> baseActivityPageResult = baseActivityService.queryPage(request, page);
        log.info("分页查询通用活动，出参{}", JSON.toJSONString(baseActivityPageResult));
        return RestResult.success(baseActivityPageResult);
    }
}
